<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/28/0028
 * Time: 9:42
 */

namespace app\sports_admin\model;


use think\Model;

class AdminRule extends Model
{
    protected $table = 'admin_rule';

    protected $pl = 'id';

    protected $autoWriteTimestamp = true;

    protected $hidden = ['create_time','update_time'];
    //获取管理员权限
    public function getRule()
    {
        return $this->belongsTo('rule','rule_id','id');
    }

    /**
     * 修改管理员权限
     * @param $adminId 管理员id
     * @param $ruleId 需要修改的权限id
     */
    public static function updateRule($adminId,$ruleId)
    {
        return self::where('admin_id',$adminId)->update(['rule_id'=>$ruleId]);
    }
}